package pageobjectpattern;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;


public class LoginPage extends Page {
		private String loginButtonPath = "//*[@id='loginButton']";
		public static final String LOGIN = "admin";
		public static final String PASSWORD = "admin";
		
        public LoginPage(WebDriver driver){
                super(driver);
                chooseAddress("localhost:8084/MyWeb1");
        }
        
        public boolean isOpen() throws InterruptedException{
            try{
            	findElement("//*[@id='login']");
            } catch(NoSuchElementException e){
                    return false;
            }
            return true;
        }
        
        public MainPage login(String login, String password){
        		
        		insertText("//*[@id='login']", login);
        		insertText("//*[@id='password']", password);
                
                clickXPath(loginButtonPath);
                return new MainPage(driver);
        }
}

